/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "hhdIHObject.h"
#include "hhdString.h"
#include "hhdAssert.h"
#include "hhdSmartPtr.hpp"
#include "tinyxml.h"

#define ContentH(long_name, short_name)\
	public:\
		const char8_t* contentName() const { return #short_name; }\
		static const char8_t* getContentName() { return #short_name; }\
		uint32_t getContentID() const { return _content_id; }\
		static uint32_t contentID() { return _content_id; }\
		void create(const char8_t* in_path);\
	private:\
		static void setContentID(uint32_t in_id) { _content_id = in_id; }\
		static uint32_t _content_id;\
		\
		friend class ContentLibrary;\
		HObjectH(long_name);

#define ContentCPP(long_name, short_name)\
	uint32_t short_name::_content_id;\
	HObjectCPP(long_name);

namespace hhd
{
	class IGame;
	class ContentLibrary;

	class IContent : public IHObject, public RefCount
	{
	public:
		struct SerializedHeader 
		{
			char8_t magic_number[8];	// ascii values for 1080720'\0', also lets us know endian mismatch
			char8_t type_id[8];			// ascii human interpretable content type. e.g. "scene", "texture", "mesh"
			uint64_t byte_length;		// length of the data
		};

		IContent() {}
		virtual ~IContent() {}

		virtual const char8_t* contentName() const = 0;
		virtual uint32_t getContentID() const = 0;

		const String& getPath() const { return _path; }
		virtual void create(const char8_t* in_path) = 0;
			
	protected:
		friend class ContentLibrary;

		String _path;
	};
}